//
//  FinishTableViewCell.m
//  CloudMD
//
//  Created by apple on 16/2/18.
//  Copyright (c) 2016年 HuaZhengInfo. All rights reserved.
//

#import "FinishTableViewCell.h"

@implementation FinishTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{

    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self buildUI];
    }
    return self;
}


- (void)buildUI{
    
    _textView = [[XYTextView alloc] initWithFrame:CGRectMake(10, 0, SCR_W - 20, SCR_H/9)];
    _textView.backgroundColor = [UIColor whiteColor];
    _textView.font = [UIFont systemFontOfSize:14.f];
    _textView.textColor = [UIColor blackColor];
    _textView.textAlignment = NSTextAlignmentLeft;
    //自定义键盘上面完成toolbar
    UIToolbar *customAccessoryView = [[UIToolbar alloc]initWithFrame:(CGRect){0,0,SCR_W,40}];
    customAccessoryView.barTintColor = [UIColor whiteColor];
    UIBarButtonItem *space = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
    UIButton *sendButton = [UIButton buttonWithType:UIButtonTypeCustom];
    sendButton.frame = CGRectMake(0, 0, 40, 40);
    [sendButton setTitle:@"完成" forState:UIControlStateNormal];
    [sendButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [sendButton addTarget:self action:@selector(doneClick) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *finish = [[UIBarButtonItem alloc] initWithCustomView:sendButton];
    [customAccessoryView setItems:@[space,space,finish]];
    _textView.inputAccessoryView = customAccessoryView;
    
    [self.contentView addSubview:_textView];
    
    
//    NSString * str = _textView.text;
////    NSLog(@"%@",str);
//    NSUserDefaults * textFaults = [NSUserDefaults standardUserDefaults];
//    [textFaults setObject:str forKey:@"TEXT"];
    
}

- (void)doneClick {
    [_textView resignFirstResponder];
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{

    [_textView resignFirstResponder];
    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
